<template>
  <div>

    <div class="Logout">
      <Logout>退出</Logout>
    </div>
    <h1>更新课程信息</h1>

    <el-input style="width: 800px" size="medium" v-model="cno" placeholder="请输入课程编号" prefix-icon="el-icon-price-tag" maxlength="10" show-word-limit clearable></el-input>
    <el-input style="width: 800px" size="medium" v-model="cname" placeholder="请输入课程名" prefix-icon="el-icon-coordinate" maxlength="50" show-word-limit clearable></el-input>
    <el-input style="width: 800px" size="medium" v-model="cclasstime" placeholder="请输入课时" prefix-icon="el-icon-tickets" maxlength="5" show-word-limit clearable></el-input>
    <el-input style="width: 800px" size="medium" v-model="ccycle" placeholder="请输入上课时间" prefix-icon="el-icon-date" maxlength="10" show-word-limit clearable></el-input>
    <el-input style="width: 800px" size="medium" v-model="camount" placeholder="请输入课程费用" prefix-icon="el-icon-coin" maxlength="10" show-word-limit clearable></el-input>
    <el-input style="width: 800px" size="medium" v-model="caddress" placeholder="请输入上课教室" prefix-icon="el-icon-location" maxlength="50" show-word-limit clearable></el-input>
    <el-input style="width: 800px" size="medium" v-model="tno" placeholder="请输入教师编号" prefix-icon="el-icon-s-check" maxlength="10" show-word-limit clearable></el-input>
    <el-input style="width: 800px" size="medium" v-model="cneed" placeholder="请输入课程所需人数" prefix-icon="el-icon-star-off" maxlength="5" show-word-limit clearable></el-input>
    <el-input style="width: 800px" size="medium" v-model="cjoin" placeholder="请输入课程已报名人数" prefix-icon="el-icon-star-on" maxlength="5" show-word-limit clearable></el-input>
    <el-row>
      <el-button @click="updateBtn" type="success" icon="el-icon-upload">提交</el-button>
    </el-row>
  </div>
</template>

<script>
import Logout from "./Logout";
export default {
  name: "UpdateCourse",
  components:{Logout},
  created(){
    this.cno = this.$route.query.cno;
    this.cname = this.$route.query.cname;
    this.cclasstime = this.$route.query.cclasstime;
    this.ccycle = this.$route.query.ccycle;
    this.camount = this.$route.query.camount;
    this.caddress = this.$route.query.caddress;
    this.tno = this.$route.query.tno;
    this.cneed = this.$route.query.cneed;
    this.cjoin = this.$route.query.cjoin;

  },
  methods: {
    // search(){
    //
    // },
    updateBtn(){
      let data = {
        cno:this.cno,
        cname:this.cname,
        cclasstime:this.cclasstime,
        ccycle:this.ccycle,
        camount:this.camount,
        caddress:this.caddress,
        tno:this.tno,
        cneed:this.cneed,
        cjoin:this.cjoin,

      };
      this.$axios.post(`/EditCourse`,data).then((res) => {
        console.log(res);
        if(res.data.msg ==="更新成功"){
          alert("修改成功");
        } else {
          alert(res.data.msg);
        }
      });
    }
  },

  data() {
    return {
      cno:'',
      cname:'',
      cclasstime:'',
      ccycle:'',
      camount:'',
      caddress:'',
      tno:'',
      cneed:'',
      cjoin:'',
    }
  }
}
</script>

<style scoped>

</style>
